<template>
	<view>
		<u-empty text="内容为空" mode="list" v-if="friendList.length<1"></u-empty>
		<!-- 评论 -->
		<view class="ml30 mt30 mr30 flex" v-for="(item,i) in friendList" :key='i' v-else
			@click.stop="$jump('/pages/friend/detail?id='+item.id)">
			<!-- 头像 -->
			<image :src="item.shop.avatar" class="w70 h70 radius70 mr20" mode="aspectFill"></image>
			<!-- 右边 -->
			<view class="flex1 pb20 u-border-bottom">
				<!-- 上面 -->
				<view class="flex row-between mb20">
					<text class="fs28">{{item.shop.name}}</text>
					<text class="fs24 color9">{{item.create_time}}</text>
				</view>
				<!-- 中间 -->
				<view class="fs28 mb20">{{item.name}}</view>
				<view class="flex commentimgBox flex-wrap mb20">
					<image :src="item2" class="radius16 w190 h180 mr10 mb10" v-for="(item2,i2) in item.images" :key='i2' mode="aspectFill">
					</image>
				</view>
				<view class="flex  row-between color9 fs24">
					<view class="" @click.stop="delfriend(item)">
						<text class="cuIcon-deletefill color-red fs30 mr20"></text>
						<text class="fs24 color-red">删除</text>
					</view>
					<view class="flex  col-center">
						<view class="mr50 fs28 flex col-center">
							<text class="cuIcon-attention fs40"></text>
							<text>{{item.browse}}</text>
						</view>
						<view class="mr50 flex col-center fs28">
							<!-- <text class="cuIcon-comment fs40"></text> -->
							<text :class="[item.comment>0?'color-red' : '']">评论{{item.comment}}</text>
						</view>
						<view class="fs28 flex col-center">
							<u-icon name="thumb-up" size="40"></u-icon>
							<!-- <u-icon name="thumb-up-fill" color="#D23030"></u-icon> -->
							<text>{{item.category_id}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- //评论 -->
	</view>
</template>

<script>
	export default {
		name: 'friendAdmin',
		onLoad() {
			
		},
		onShow() {
			this.query.page=1
			this.getmyCircle()
		},
		data() {
			return {
				query: {
					page: 1,
					size: 10
				},
				friendList: []
			};
		},
		methods: {
			//获取收藏
			getmyCircle(cd) {
				this.$api.myCircle(this.query).then(res => {
					console.log(res)
					cd?this.friendList = [...this.friendList, ...res.data] : this.friendList=res.data
				})
			},
			//删除朋友圈
			delfriend(item) {
				let that = this
				uni.showModal({
					title: '提示',
					content: '确定删除该条朋友圈么?',
					success(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							that.$api.deleteCircle({
								id: item.id
							}).then(res2 => {
								console.log(res2)
								if (res2.code == 1) {
									that.$msg('删除成功')
									//重置
									that.query.page = 1
									//清空数据列表
									that.friendList = []
									that.getmyCircle()
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
				
			}
		},
		//触底加载更多
		onReachBottom() {
			this.query.page++
			this.getmyCircle('cd')
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #FFFFFF;
	}

	.commentimgBox {
		image {
			width: 32%;
		}
	}
</style>
